<?php
//------------------------
// 属性,商品属性
// platform_type_attr , platform_goods_attr
//-------------------------
namespace app\common\model;

use think\Model;
use think\Db;

class GoodsTypeAttrView extends Model{

	// 设置platform_type_attr为主表
	protected $table = 'platform_type_attr';

    // 设置当前模型的表前
    protected $connection = [
        'prefix'      => ''
    ];

	//自定义初始化
    protected function initialize()
    {
        parent::initialize();
        //TODO:自定义的初始化,连表
        $this->join('platform_goods_attr','platform_type_attr.id = platform_goods_attr.attr_id','LEFT');

        $this->field('platform_type_attr.attr_name AS attr_name,platform_type_attr.is_select AS is_select,platform_type_attr.opts AS opts,platform_goods_attr.attr_id AS attr_id,platform_goods_attr.value AS attr_value,platform_goods_attr.price AS attr_price,platform_goods_attr.id AS goods_attr_id');

        $this->order("platform_type_attr.id ASC,platform_goods_attr.id DESC");
    }

}